package com.it.travel.service.admin.impl;

import com.it.travel.dao.CategoryMapper;
import com.it.travel.dao.ProductMapper;
import com.it.travel.dao.StoryMapper;
import com.it.travel.dao.UserMapper;
import com.it.travel.service.admin.AdminIndexService;
import com.it.travel.vo.Result;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;

@Service
public class AdminIndexServiceImpl implements AdminIndexService {
    @Resource
    private StoryMapper storyMapper;

    @Resource
    private CategoryMapper categoryMapper;

    @Resource
    private ProductMapper productMapper;

    @Resource
    private UserMapper userMapper;

    @Override
    public Result<?> getInfo() {
        HashMap<String, Object> map = new HashMap<>();
        Integer storyTotal = storyMapper.selectCount(null);
        Integer categoryTotal = categoryMapper.selectCount(null);
        Integer productTotal = productMapper.selectCount(null);
        Integer userTotal = userMapper.selectCount(null);
        map.put("storyTotal", storyTotal);
        map.put("categoryTotal", categoryTotal);
        map.put("productTotal", productTotal);
        map.put("userTotal", userTotal);
        return Result.success(map, "yes");

    }
}
